<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>按钮</title>
</head>
<body>
<div id="d">
<button>1</button>
<button>2</button>
    <button>1</button>
    <button>2</button>
    <button>1</button>
    <button>2</button>
</div>
<button type="button" onclick="test()">按钮</button>
<script>
    function test(){
       var d=document.getElementById('d')
        var dCopy=d.cloneNode(true)//true是深克隆，false是浅克隆
        d.innerHTML='123456'
        d.innerHTML='<a href="https://www.baidu.com">baidu</a>'
         var a = document.createElement('a')
         a.href="https://www.baidu.com"
         var aInnerText=document.createTextNode("百度一下")
         a.append(aInnerText)
        d.append(a)
         d.insertBefore(a,document.getElementsByTagName('button')[1])
        d.removeChild(document.getElementsByTagName('button')[1])
        d.innerHTML=d.innerHTML.substring(1,5)

    }
</script>
</body>
</html>
